import { mpRequest } from "../utils/request";
import { IResponse } from "./types";
import { IUpdateUserReq } from "./types/login";

/**
 * 登录
 */
export const apiMpLogin = (code: string) => {
  return mpRequest<IResponse<string>>({
    url: "/auth/login",
    method: "post",
    data: { code },
  });
};

/**
 * 获取用户信息
 */
export const apiQueryUser = () => {
  return mpRequest({
    url: "/user",
    method: "get",
  });
};

/**
 * 更新用户微信信息
 */
export const apiUpdateUser = (data: IUpdateUserReq) => {
  return mpRequest({
    url: "/auth/user",
    method: "post",
    data,
  });
};

/**
 * 获取用户手机号码
 */
export const apiGetPhone = (code: string) => {
  return mpRequest({
    url: `/auth/phone`,
    method: "post",
    data: { code },
  });
};

/**
 * @description 登出
 */
export const apiLoginout = () => {
  return mpRequest({
    url: "/auth/logout",
    method: "post",
  });
};
